x86/intel: protect set_cpuidmask() against #GP faults
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Aug 2014 12:28:12 +0000 (14:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 22 Aug 2014 12:28:12 +0000 (14:28 +0200)
commit02926b1729849c421d990009343a5456897e214a
tree2ad0b3b04b9fbe499abfe3a63752301064648a08
parentdea878490c5b0b425dc235df1380824ecca77624
x86/intel: protect set_cpuidmask() against #GP faults

Virtual environments such as Xen HVM containers and VirtualBox do not
necessarily provide support for feature masking MSRs.

As their presence is detected by model numbers alone, and their use predicated
on command line parameters, use the safe() variants of {wr,rd}msr() to avoid
dying with an early #GP fault.

While playing in this function, make some further improvements.

* Rename the masking MSR names for consistency, and name the CPU models for
  the benefit of humans reading the code.
* Correct the CPU selection as specified in the flexmigration document.  All
  steppings of 0x17 and 0x1a are stated to have masking MSRs.
* Provide log messages indicating the masks applied, or lack of masking
  capabilities.
* In the case of faulting support being available and masking command line
  options specified, provide a log message indicating the lack of masking.

References:
http://www.intel.com/content/www/us/en/virtualization/virtualization-technology-flexmigration-application-note.html
http://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/cpu/intel.c
xen/include/asm-x86/msr-index.h